package com.laowang.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by Administrator on 2019/1/16.
 */
@Controller
@Slf4j
@RequestMapping("/weixin")
public class WeixinController {
    @RequestMapping("/auth")
    public void auth(@RequestParam("code") String code){
        log.info("进入微信auth的方法");
        log.info("code={}",code);
       String url= "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx1ebc0352d940af20&secret=defc8382f4d04721251e10cd4c6f7ba1&code="+code+"&grant_type=authorization_code";
        RestTemplate restTemplate = new RestTemplate();
        String response = restTemplate.getForObject(url, String.class);

        log.info("response={}",response);
    }
}
